package apis

import (
	"gitee.com/byx_darwin/ncloud-go/core"
	"gitee.com/byx_darwin/ncloud-go/core/net/consts"
)

type QueryMetricConditions struct {
	StartTime  int64    `json:"start_time"`
	EndTime    int64    `json:"end_time"`
	Interval   int64    `json:"interval"`
	DomainList []string `json:"domain_list"`
}
type QueryMetricRequest struct {
	core.NCloudRequest
	QueryMetricConditions
}

func NewQueryMetricRequest(startTime, endTime, interval int64) *QueryMetricRequest {
	return &QueryMetricRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/metric",
			Method: consts.MethodPost,
		},
		QueryMetricConditions: QueryMetricConditions{
			StartTime: startTime,
			EndTime:   endTime,
			Interval:  interval,
		},
	}
}
func NewQueryMetricRequestWithDomains(startTime, endTime, interval int64, list []string) *QueryMetricRequest {
	return &QueryMetricRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/metric",
			Method: consts.MethodPost,
		},
		QueryMetricConditions: QueryMetricConditions{
			StartTime:  startTime,
			EndTime:    endTime,
			Interval:   interval,
			DomainList: list,
		},
	}
}

type QueryMetricResponse struct {
	Ok      bool       `json:"ok"`
	Msg     string     `json:"msg"`
	TrackID string     `json:"track_id"`
	Data    MetricData `json:"data"`
}

type MetricData struct {
	Interval   int64          `json:"interval"`
	MetricList []MetricObject `json:"metric_list,omitempty"`
}

type MetricObject struct {
	Time     uint64            `json:"time"`
	Domain   string            `json:"domain"`
	Province string            `json:"province"`
	Isp      string            `json:"isp"`
	Flow     uint64            `json:"flow"`
	PV       uint64            `json:"pv"`
	Qps      float64           `json:"qps"`
	HttpCode map[string]uint64 `json:"http_code"`
}
